<!--

    Copyright © 2016-2025 The Thingsboard Authors

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

        http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.

-->
<div class="flex flex-1 flex-row items-center justify-start gap-4" [formGroup]="filterPredicateFormGroup">
  <div class="tb-form-panel no-border no-padding-right flex-1" style="flex-direction: row">
    @switch (type) {
      @case (filterPredicateType.STRING) {
        <div class="tb-form-row no-padding no-border column-xs w-full max-w-30% xs:max-w-full flex-1/">
          <mat-form-field hideRequiredMarker class="flex-1" appearance="outline" subscriptSizing="dynamic">
            <mat-select required formControlName="operation" placeholder="{{'filter.operation.operation' | translate}}">
              <mat-option *ngFor="let operation of stringOperations" [value]="operation">
                {{stringOperationTranslationMap.get(stringOperation[operation]) | translate}}
              </mat-option>
            </mat-select>
          </mat-form-field>
          <mat-chip-listbox formControlName="ignoreCase" [hideSingleSelectionIndicator]="true">
            <mat-chip-option color="primary" [value]="true">{{ 'alarm-rule.ignore-case' | translate }}</mat-chip-option>
          </mat-chip-listbox>
        </div>
      }
      @case (filterPredicateType.NUMERIC) {
        <div class="tb-form-row no-border no-padding no-border w-full max-w-30%">
          <mat-form-field hideRequiredMarker class="flex-1" appearance="outline" subscriptSizing="dynamic">
            <mat-select required formControlName="operation" placeholder="{{'filter.operation.operation' | translate}}">
              <mat-option *ngFor="let operation of numericOperations" [value]="operation">
                {{numericOperationTranslations.get(numericOperationEnum[operation]) | translate}}
              </mat-option>
            </mat-select>
          </mat-form-field>
        </div>
      }
      @case (filterPredicateType.BOOLEAN) {
        <div class="tb-form-row no-border no-padding no-border w-full max-w-30%">
          <mat-form-field hideRequiredMarker class="flex-1"  appearance="outline" subscriptSizing="dynamic">
            <mat-select required formControlName="operation" placeholder="{{'filter.operation.operation' | translate}}">
              <mat-option *ngFor="let operation of booleanOperations" [value]="operation">
                {{booleanOperationTranslations.get(booleanOperationEnum[operation]) | translate}}
              </mat-option>
            </mat-select>
          </mat-form-field>
        </div>
      }
      @case (filterPredicateType.COMPLEX) {
        <div class="tb-form-row no-border no-padding flex-1">
          <button type="button" style="--mat-outlined-button-horizontal-padding: 3px 0px 12px;"
                  class="block w-full"
                  mat-stroked-button color="primary"
                  (click)="openComplexFilterDialog()">
            <div class="flex items-center gap-2">
              <span class="w-full text-start" translate>filter.complex-filter</span>
              <mat-icon class="tb-mat-20 tb-alarm-rule-schedule-edit-icon">edit</mat-icon>
            </div>
          </button>
        </div>
      }
    }
    @if (type !== filterPredicateType.COMPLEX) {
      <tb-alarm-rule-filter-predicate-value class="flex-full"
                                            [arguments]="arguments"
                                            [argumentInUse]="argumentInUse"
                                            [valueType]="valueType"
                                            formControlName="value">
      </tb-alarm-rule-filter-predicate-value>
    }
  </div>
</div>
